﻿CREATE PROCEDURE [dbo].[GetStudents] 
	@StudentId INT = -1	
AS
BEGIN
BEGIN TRY
	IF (@StudentId = -1)
		SELECT id, name FROM Students
	ELSE
		SELECT id, name FROM Students WHERE id = @StudentId
	
	DECLARE @I INT = 0
	WHILE (@I < 10)
	BEGIN

		IF (@StudentId = -1)
		SELECT id, name FROM Students
	ELSE
		SELECT id, name FROM Students WHERE id = @StudentId

	SET @I = @I + 1

	END

END TRY
BEGIN CATCH
	DECLARE @ErrorText VARCHAR(500) = ERROR_MESSAGE()

END CATCH
	return @@ROWCOUNT
END
